 package com.gmako.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gmako.dao.BaseDAO;
import com.gmako.entity.Activityinfo;
import com.gmako.entity.Packageinfo;
import com.gmako.service.ActivityinfoService;
import com.gmako.utils.Pager;
@Service
public class ActivityinfoServiceImpl implements ActivityinfoService {
	@Autowired
	private BaseDAO baseDAO;
	public Pager findPagerHql(final int pageSize, final int pageNo,int type){
		 String sqlCount=null,SqlList=null;
		 if (type==1) {
			 sqlCount="select count(*) from Activityinfo";
			 SqlList="select * from Activityinfo order by activityinfoPrice desc";
		}
		 if (type==2) {
			 sqlCount="select count(*) from Activityinfo";
			 SqlList="select * from Activityinfo order by activityinfoPrice asc";
		 }
		 if (type==3) {
			 sqlCount="select count(*) from Activityinfo";
			 SqlList="select * from Activityinfo order by beginTime desc";
		 }
		 if (type==4) {
			 sqlCount="select count(*) from Activityinfo";
			 SqlList="select * from Activityinfo order by activityStart desc";
		 }
		return baseDAO.findPagerSql(pageSize, pageNo, sqlCount,SqlList,Activityinfo.class);
	}
	
	public void insert(Activityinfo activityinfo){
		baseDAO.save(activityinfo);
	}
	
	
   /**
	 * 获得活动
	 * @param id
	 * @return
	 */
	public Activityinfo getActivityinfo(int id) {
		String hql="from Activityinfo where id="+id;
		return  (Activityinfo)baseDAO.loadObject(hql);
	}
}

